/*
* 
*  img 图片展示
*  超链接在新窗口打开
*  _Blank是新窗口

*_Self是自身

*_Parent是父窗口

*_Top是顶层窗口
* */

function img(value, row, index) {
    if( value!= null && value!= ''){
        return "   <div class=\"gallerys\"><img src='" +value+"' style='width: 50px;height: 50px;' onerror='whenError(this)' class='gallery-pic' onclick='$.openPhotoGallery(this)'></div>"
    }
    return "<div class=\"gallerys\"><img  style='width: 50px;height: 50px;' src='"+ basePath +"images/main/default.jpg' class='gallery-pic' onclick='$.openPhotoGallery(this)'></div>";
}

function time(value, row, index) {
    return "<div style='width: 80px;'>" + value + "</div>";
}

function whenError(a){
    a.onerror=null;
    // 现在的错误默认显示
    a.src=basePath+'images/main/default.jpg';
}

function showDeflut(a) {
    a.src=basePath+'images/main/default.jpg';
}

// 枚举的使用
function listenum(list,value) {
    if(list != null){
        for(var i in list){
            if(list[i].enumValue == value){
                return list[i].enumTxt;
            }
        }
    }
    return "";
}

// 时间的格式化
function dateFtt(fmt,date)
{ //author: meizz
    var o = {
        "M+" : date.getMonth()+1,                 //月份
        "d+" : date.getDate(),                    //日
        "h+" : date.getHours(),                   //小时
        "m+" : date.getMinutes(),                 //分
        "s+" : date.getSeconds(),                 //秒
        "q+" : Math.floor((date.getMonth()+3)/3), //季度
        "S"  : date.getMilliseconds()             //毫秒
    };
    if(/(y+)/.test(fmt))
        fmt=fmt.replace(RegExp.$1, (date.getFullYear()+"").substr(4 - RegExp.$1.length));
    for(var k in o)
        if(new RegExp("("+ k +")").test(fmt))
            fmt = fmt.replace(RegExp.$1, (RegExp.$1.length==1) ? (o[k]) : (("00"+ o[k]).substr((""+ o[k]).length)));
    return fmt;
}


/*通用format创建人*/
function formatterCreator(value, row, index) {
    if (!value || value == '') {
        return '';
    }
    var msg = "创建人：" + (row.creator?row.creator:"") + "\n创建时间：" + (row.gmtCreate?row.gmtCreate:"");
    return "<span style='cursor:pointer;' title='" + msg + "'>" + value + "</span>";
}

/*通用format更新人*/
function formatterOperator(value, row, index) {
    if (!value || value == '') {
        return '';
    }
    var msg = "最后编辑人：" + (row.operator?row.operator:"") + "\n最后编辑时间：" + (row.gmtModify?row.gmtModify:"");
    return "<span style='cursor:pointer;' title='" + msg + "'>" + value + "</span>";
}

/*通用format提交人*/
function formatterCommit(value, row, index) {
    if (!value || value == '') {
        return '';
    }
    var msg = "提交人：" + (row.operatorCommit?row.operatorCommit:"") + "\n提交时间：" + (row.gmtPublish?row.gmtPublish:"");
    return "<span style='cursor:pointer;' title='" + msg + "'>" + value + "</span>";
}

/*通用format审核人*/
function formatterCheck(value, row, index) {
    if (!value || value == '') {
        return '';
    }
    var msg = "审核人：" + (row.operator?row.operator:"") + "\n审核时间：" + (row.gmtCreate?row.gmtCreate:"");
    return "<span style='cursor:pointer;' title='" + msg + "'>" + value + "</span>";
}

//通用isv服务商
function formatIsv(value, row, index) {
    if (!value || value == '') {
        return '';
    }
    return '<p class="isvInfoView" >'+value+'</p> ';
}

//通用名称
function formatName(value, row, index) {
    if (!value || value == '') {
        return '';
    }
    return '<p class="infoView" >'+value+'</p>';
}

// 二级级科室
function formattercDeptName(value, row, index) {
    // not empty oneBasicDoctorInfo && not empty oneBasicDoctorInfo.cDeptCode &&
    // not empty oneBasicDoctorInfo.pDeptCode?oneBasicDoctorInfo.cDeptCode : ''
    // console.log("一级科室cDeptName:"+row.cDeptName+"二级科室pDeptName:"+row.pDeptName);
   if(row.cDeptName != null && row.pDeptCode != null){
       return row.cDeptName;
   }else{
       return "";
   }
}
// 一级科室
function formatterpDeptName(value, row, index) {
    // ${not empty oneBasicDoctorInfo && not empty oneBasicDoctorInfo.cDeptCode &&
    // empty oneBasicDoctorInfo.pDeptCode?oneBasicDoctorInfo.cDeptCode : oneBasicDoctorInfo.pDeptCode}"
    // 一级科室cDeptName:内科二级科室pDeptName:undefined
    // 一级科室cDeptName:普通内科二级科室pDeptName:内科

    if(row.pDeptName == null && row.cDeptName != null){
        return row.cDeptName;
    }else{
        return row.pDeptName;
    }
}
